package Demo1;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-09-27
 * Time: 8:23
 */
class Student implements Comparable<Student>{
    public String name;
    public int[] score;
    public String level;
    public int avg;
    public int overallScore;
    public String overallLevel;

    public Student(String name, int[] score, String level) {
        this.name = name;
        this.score = score;
        this.level = level;
    }

    @Override
    public int compareTo(Student o) {
        return o.overallScore - this.overallScore;
    }
}
public class Test {
    public static Scanner input = new Scanner(System.in);
    public static void main(String[] args) {
        Student[] stu = new Student[3];
        //求每个同学平均分
        String[] name = {"Z","L","W"};
        int[][] score = {{60,71,80},{70,81,90},{80,81,90}};
        String[] level = {"A","B","C"};
        for (int i = 0; i < stu.length; i++) {
            stu[i] = new Student(name[i],score[i],level[i]);
        }

        for (int i = 0; i < stu.length; i++) {
            int sum = 0;
            for (int j = 0; j < stu[i].score.length; j++) {
                sum += stu[i].score[j];
            }
            stu[i].avg = sum / score[i].length;
            System.out.println(name[i] + "平均分为" + stu[i].avg);
            stu[i].overallScore = stu[i].avg;
        }

        for (int i = 0; i < stu.length; i++) {
            if(stu[i].level.equals("A")){
                stu[i].overallScore += 10;
                if (stu[i].overallScore > 100){
                    stu[i].overallScore = 100;
                }
            }else if(level[i].equals("B")){
                stu[i].overallScore += 5;
                if (stu[i].overallScore > 100){
                    stu[i].overallScore = 100;
                }
            }
            stu[i].overallLevel = levelJudge(stu[i].overallScore);
            System.out.println(stu[i].name + " " +  stu[i].overallLevel);
        }
        Arrays.sort(stu);
        for (int i = 0; i < stu.length; i++) {
            System.out.println("名字：" + stu[i].name + " 平均分：" + stu[i].avg + " 平时表现" + stu[i].level + " 最终成绩 " + stu[i].overallScore + "成绩等级 " + stu[i].overallLevel);
        }
    }
    public static String levelJudge(int overallScore){
        if(overallScore >= 90){
            return "优秀";
        }else if(overallScore >= 80){
            return "良好";
        }else if(overallScore >= 70){
            return "中等";
        }else if(overallScore >= 60){
            return "及格";
        }else {
            return "不合格";
        }
    }
}
